#include "playlessonvideo.h"
#include "ui_playlessonvideo.h"
#include <QFileDialog>

PlayLessonVideo::PlayLessonVideo(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PlayLessonVideo),
    fileName(""),
    media(new Phonon::MediaObject(this)),
    ao(new Phonon::AudioOutput(Phonon::VideoCategory, this)),
    vw(new Phonon::VideoWidget)
{
    ui->setupUi(this);
    connect(ui->openBtn, SIGNAL(clicked()),this,SLOT(open()));
    ui->horizontalLayout->addWidget(vw);

    Phonon::createPath(media, ao);
    Phonon::createPath(media, vw);
}

PlayLessonVideo::~PlayLessonVideo()
{
    delete ui;
}

void PlayLessonVideo::playVideo()
{
    media->play();
}

void PlayLessonVideo::stopVideo()
{

}

void PlayLessonVideo::open()
{

    fileName = QFileDialog::getOpenFileName(0,"Open","","");

    if(!fileName.isEmpty())
        media->setCurrentSource(Phonon::MediaSource(fileName));


}
